package com.ibeeking.found.report.service.common.vo;


import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.util.DigestUtils;

import java.nio.charset.Charset;
import java.util.Date;

/**
 * 基础传输对象
 * @author lr
 * @since 2021-01-12
 */
@Data
public class ReportBaseVO {

    /**
     * 盐值
     */
    private static String SLAT = "354816d26912441ab280f08831c38453";

    @Override
    public String toString(){
        return JSON.toJSONString(this);
    }

    private Long id;

    /**
     * 创建人
     */
    private String createBy;

    /**
     * 前端展示
     */
    private String createByView;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 修改人
     */
    private String modifyBy;


    /**
     * 前端展示
     */
    private String modifyByView;

    /**
     * 修改时间
     */
    private String modifyTime;

    /**
     * 版本号
     */
    private Integer version;

    /**
     * accessKey用于校验单条记录权限，防止越权
     * @return
     */
    public String getAccessKey() {
        if (id == null) {
            return null;
        }
        return DigestUtils.md5DigestAsHex((SLAT + "_" + id).getBytes(Charset.forName("UTF-8")));
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getModifyBy() {
        return modifyBy;
    }

    public void setModifyBy(String modifyBy) {
        this.modifyBy = modifyBy;
    }

    public String getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(String modifyTime) {
        this.modifyTime = modifyTime;
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public String getCreateByView() {
        return createByView;
    }

    public void setCreateByView(String createByView) {
        this.createByView = createByView;
    }

    public String getModifyByView() {
        return modifyByView;
    }

    public void setModifyByView(String modifyByView) {
        this.modifyByView = modifyByView;
    }
}
